// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import zombie.iso.sprite.IsoSprite;

public class IsoFloorBloodSplat {
    public static final float FADE_HOURS = 72.0F;
    public static HashMap<String, IsoSprite> SpriteMap = new HashMap();
    public static String[] FloorBloodTypes = new String[]{
        "blood_floor_small_01",
        "blood_floor_small_02",
        "blood_floor_small_03",
        "blood_floor_small_04",
        "blood_floor_small_05",
        "blood_floor_small_06",
        "blood_floor_small_07",
        "blood_floor_small_08",
        "blood_floor_med_01",
        "blood_floor_med_02",
        "blood_floor_med_03",
        "blood_floor_med_04",
        "blood_floor_med_05",
        "blood_floor_med_06",
        "blood_floor_med_07",
        "blood_floor_med_08",
        "blood_floor_large_01",
        "blood_floor_large_02",
        "blood_floor_large_03",
        "blood_floor_large_04",
        "blood_floor_large_05"
    };
    public float x;
    public float y;
    public float z;
    public int Type;
    public float worldAge;
    public int index;
    public int fade;
    IsoChunk chunk;

    public IsoFloorBloodSplat() {
    }

    public IsoFloorBloodSplat(float _x, float _y, float _z, int _Type, float _worldAge) {
        this.x = _x;
        this.y = _y;
        this.z = _z;
        this.Type = _Type;
        this.worldAge = _worldAge;
    }

    public void save(ByteBuffer output) {
        int int0 = (int)(this.x / 10.0F * 255.0F);
        if (int0 < 0) {
            int0 = 0;
        }

        if (int0 > 255) {
            int0 = 255;
        }

        int int1 = (int)(this.y / 10.0F * 255.0F);
        if (int1 < 0) {
            int1 = 0;
        }

        if (int1 > 255) {
            int1 = 255;
        }

        int int2 = (int)(this.z / 8.0F * 255.0F);
        if (int2 < 0) {
            int2 = 0;
        }

        if (int2 > 255) {
            int2 = 255;
        }

        output.put((byte)int0);
        output.put((byte)int1);
        output.put((byte)int2);
        output.put((byte)this.Type);
        output.putFloat(this.worldAge);
        output.put((byte)this.index);
    }

    public void load(ByteBuffer input, int WorldVersion) throws IOException {
        if (WorldVersion >= 65) {
            this.x = (float)(input.get() & 255) / 255.0F * 10.0F;
            this.y = (float)(input.get() & 255) / 255.0F * 10.0F;
            this.z = (float)(input.get() & 255) / 255.0F * 8.0F;
            this.Type = input.get();
            this.worldAge = input.getFloat();
            if (WorldVersion >= 73) {
                this.index = input.get();
            }
        } else {
            this.x = input.getFloat();
            this.y = input.getFloat();
            this.z = input.getFloat();
            this.Type = input.getInt();
            this.worldAge = (float)zombie.GameTime.getInstance().getWorldAgeHours();
        }
    }
}
